package tec.stan.ling.topo.graph.editpart;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;

import tec.stan.ling.core.top.model.Device;
import tec.stan.ling.core.top.model.Link;
import tec.stan.ling.core.top.model.Subnet;

/**
 * Map model object to EditPart object
 * 
 * @author Stan 张新潮
 * @since 2010-4-8
 */
public class NEEditPartFactory implements EditPartFactory {

	@Override
	public EditPart createEditPart(EditPart context, Object model) {
		EditPart editPart = null;

		if (model instanceof Subnet) {
			if (context == null) {
				editPart = new MapEditPart();
			} else {
				editPart = new SubnetEditPart();
			}
		} else if (model instanceof Device) {
			editPart = new DeviceEditPart();
		} else if (model instanceof Link) {
			editPart = new LinkEditPart();
		}
		if (editPart != null) {
			editPart.setModel(model);
		}
		return editPart;
	}

}
